package co.wangdao.xingshaoye.view.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import co.wangdao.xingshaoye.R;
import co.wangdao.xingshaoye.utils.Nickname_dialog;

public class Personal_data extends Activity {
    private RelativeLayout Pinding_phone;//绑定手机
    private RelativeLayout Change_password;//修改密码
    private LinearLayout backspace;//返回
    private RelativeLayout head_portrait;//头像
    private RelativeLayout nickname;//昵称
    private TextView nickname2;//昵称
        private RelativeLayout gender;//性别
    public void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.personal_data);
        head_portrait= (RelativeLayout) findViewById(R.id.head_portrait);
        nickname=(RelativeLayout) findViewById(R.id.nickname);
        nickname2= (TextView) findViewById(R.id.nickname2);
        gender=(RelativeLayout) findViewById(R.id.gender);
        Pinding_phone=(RelativeLayout) findViewById(R.id.Pinding_phone);
        Change_password=(RelativeLayout) findViewById(R.id.Change_password);
        backspace=(LinearLayout)findViewById(R.id.backspace);


        /*为昵称设置监听事件*/
        nickname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                final Nickname_dialog Nickname_dialog = new Nickname_dialog(Personal_data.this,"");

                Nickname_dialog.setPositiveButton(R.string.confirm, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        EditText edit = (EditText)Nickname_dialog.findViewById(R.id.message);

                        //edit.getText().toString() ; // =获得edit中的值
                        nickname2.setText(edit.getText().toString());
                        Nickname_dialog.dismiss();
                    }
                });
                Nickname_dialog.setPositiveButton(R.string.cancel, new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        // TODO Auto-generated method stub
                        Nickname_dialog.dismiss();
                    }
                });
                Nickname_dialog.setCancelable(true);
                Nickname_dialog.show();
            }
        });

        /*为头像设置监听事件*/
        head_portrait.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String[]items=new String[]{"手机拍照","本地图片","取消"};//显示带单选列表项的对话框
                AlertDialog.Builder builder=new AlertDialog.Builder(Personal_data.this);
               builder.setItems(items, new DialogInterface.OnClickListener() {
                   @Override
                   public void onClick(DialogInterface dialog, int which) {
                       Toast.makeText(Personal_data.this, "您选择了"+items[which], Toast.LENGTH_SHORT).show();//显示选择结果
                   }
               });
                builder.create().show();
            }
        });
        /*为性别设置监听事件*/
        gender.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String[]items=new String[]{"手机拍照","本地图片","取消"};//显示带单选列表项的对话框
                AlertDialog.Builder builder=new AlertDialog.Builder(Personal_data.this);
                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(Personal_data.this, "您选择了"+items[which], Toast.LENGTH_SHORT).show();//显示选择结果
                    }
                });
                builder.create().show();
            }
        });

        /*为绑定手机设置监听事件*/
        Pinding_phone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Personal_data.this,Binding_phone.class);
                startActivity(intent);
            }
        });
        /*修改密码设置监听*/
        Change_password.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Personal_data.this,Change_password.class);
                startActivity(intent);
            }
        });
        /*为返回设置监听事件*/
        backspace.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

    }

}
